package net.expectx.pay.merchant.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;

/**
 * 提示标签
 * @author lijian
 */
public class TipTag  extends TagSupport {
    private String tipMessage;
    private String widthClass;

    public String getTipMessage() {
        return tipMessage;
    }

    public void setTipMessage(String tipMessage) {
        this.tipMessage = tipMessage;
    }

    public String getWidthClass() {
        return widthClass;
    }

    public void setWidthClass(String widthClass) {
        this.widthClass = widthClass;
    }

    @Override
    public int doEndTag() throws JspException {
        StringBuffer buffer=new StringBuffer();
        JspWriter out = this.pageContext.getOut();
        try {
            buffer.append("<div class=\"option-tips\">\n");
            if (null ==widthClass){
                buffer.append("<div class=\"layui-collapse full-width\">\n");
            }else{
                buffer.append("<div class=\"layui-collapse "+widthClass+"\">\n");
            }
            buffer.append("<div class=\"layui-colla-item\">\n");
            buffer.append("<h2 class=\"layui-colla-title\">操作提示</h2>\n");
            buffer.append("<div class=\"layui-colla-content layui-show\">\n");
            buffer.append("<ul>\n");
            String [] tipMessages=tipMessage.split(";");
            for (String message:tipMessages){
                buffer.append("<li>"+message+"</li>\n");
            }
            buffer.append("</ul>\n");
            buffer.append(" </div>\n");
            buffer.append("</div>\n");
            buffer.append("</div>\n");
            buffer.append("</div>");
            out.println(buffer.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return super.doEndTag();
    }
}
